﻿/****************************** Module Header ******************************\
 * Module Name:  DBColumnAttribute.cs
 * Module Version:  1.0.0 (2012-1-18)
 * Copyright (c) AnyEB.Com (14507247@qq.com)
 * 
 * This class is used to the data access layer. It supplies public method to 
 * add a record to database or get a list from the datatable, the parameter
 * could be an data entity or a string sql statement.
 * 
 * This source is subject to the GPL License.
 * See http://www.gnu.org/licenses/gpl.html.
 * All other rights reserved.
 * 
 * THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, 
 * EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED 
 * WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
\***************************************************************************/

using System;
using System.Collections.Generic;

namespace UCF.Core.Attribute
{
    /// <summary>
    /// 数据库字段属性类
    /// </summary>
    [System.AttributeUsage(AttributeTargets.Property)]
    public class DBColumnAttribute : System.Attribute
    {
        /// <summary>
        /// 自增长起始种子
        /// </summary>
        public int AutoIncrementSeed { get; set; }

        /// <summary>
        /// 自增长步长
        /// </summary>
        public int AutoIncrementStep { get; set; }

        /// <summary>
        /// 是否可以为NULL
        /// </summary>
        public bool CanBeNull { get; set; }

        /// <summary>
        /// 数据库注释
        /// </summary>
        public string Common { get; set; }

        /// <summary>
        /// 数据库数据类型
        /// </summary>
        public string DbType { get; set; }

        /// <summary>
        /// 默认值
        /// <para>时间类型默认值为"Now"</para>
        /// <para>布尔类型默认值为"0"</para>
        /// <para>Guid类型默认值为"new()",空值为"default"</para>
        /// </summary>
        public string DefaultValue { get; set; }

        /// <summary>
        /// 表达式
        /// <para>如：Expression="price * 6"</para>
        /// </summary>
        public string Expression { get; set; }

        /// <summary>
        /// 是否自增长字段
        /// </summary>
        public bool IsAutoIncrement { get; set; }

        /// <summary>
        /// 是否是主键
        /// </summary>
        public bool IsPrimaryKey { get; set; }

        /// <summary>
        /// 字段长度
        /// </summary>
        public string Length { get; set; }
                
        /// <summary>
        /// 字段名称
        /// </summary>
        public string Name { get; set; }

        /// <summary>
        /// 聚合索引排序
        /// <para>建议：主键列、小数目的不同值、列经常被分组排序、某范围内的数据</para>
        /// </summary>
        public short ClusteredOrdinal { get; set; }

        /// <summary>
        /// 非聚合索引排序
        /// <para>建议：主键列、大数目的不同值、列经常被分组排序、频繁更新的列、频繁修改索引列</para>
        /// </summary>
        public short NonclusteredOrdinal { get; set; }

        /// <summary>
        /// 源字段名称(用于不同数据表数据对拷)
        /// </summary>
        public string Source { get; set; }
    }
}
